import cv2
import poseModule

cap = cv2.VideoCapture(
    "/Users/serpmelon/Library/Containers/com.tencent.xinWeChat/Data/Library/Application Support/com.tencent.xinWeChat/2.0b4.0.9/f6ed33db2f6fea7a0c6f26e3eaaacd3e/Message/MessageTemp/adb1468d6f1111862cb0b0bada602f6a/Video/332_1713406198.mp4"
)
# cap = cv2.VideoCapture(0)
detector = poseModule.poseDetector()
flag = True
count = 0
while True:
    success, frame = cap.read()
    if success:
        # detector.findPose(img)
        frame = detector.findPose(frame)
        lmList = detector.findPosition(frame)
        angle = detector.findAngle(frame, 11, 23, 25)
        print(angle)
        if angle < 90 and angle > 0 and flag:
            count = count + 1
            flag = False
        if angle > 115:
            flag = True
        print(count)
        cv2.putText(
            frame, str(count), (100, 100), cv2.FONT_HERSHEY_SIMPLEX, 2, (0, 255, 255), 3
        )
        cv2.imshow("pose", frame)
    else:
        break
    cv2.imshow("pose", frame)
    if cv2.waitKey(1) == ord("q"):
        break
